using System;
using System.Collections.Generic;
using System.Xml.Serialization;

using Gonte.Collections;
using Gonte;

namespace MyUtilitiesTest
{
    public class SampleObject
    {
        private String name_;
        private String data_;

        public String Data
        {
            get { return data_; }
            set { data_ = value; }
        }

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }
    }

    public class InnerObjectWithProperties
    {
        private String prop1_;
        private String prop2_;

        public String Prop2
        {
            get { return prop2_; }
            set { prop2_ = value; }
        }

        public String Prop1
        {
            get { return prop1_; }
            set { prop1_ = value; }
        }
    }

    public class NotTooComplexTestObject
    {
        private String name_;
        private String class_;
        private int number_;
        private String text_;

        public String Text
        {
            get { return text_; }
            set { text_ = value; }
        }

        public String Class
        {
            get { return class_; }
            set { class_ = value; }
        }

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        public int Number
        {
            get { return number_; }
            set { number_ = value; }
        }

        private String innerObject_;

        [XmlElement("Inner")]
        public String InnerObject
        {
            get { return innerObject_; }
            set { innerObject_ = value; }
        }

        private InnerObjectWithProperties innerObjectWithProperties_;

        public InnerObjectWithProperties InnerObjectWithProperties
        {
            get { return innerObjectWithProperties_; }
            set { innerObjectWithProperties_ = value; }
        }

        private List<String> names_;

        [XmlElement("Name")]
        public List<String> Names
        {
            get { return names_; }
            set { names_ = value; }
        }

        private List<SampleObject> sampleObjects_;

        [XmlElement("SampleObject")]
        public List<SampleObject> SampleObjects
        {
            get { return sampleObjects_; }
            set { sampleObjects_ = value; }
        }
    }

    public class CommandInfo
    {
        private String name_;
        private String text_;
        private String type_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        public String Text
        {
            get { return text_; }
            set { text_ = value; }
        }

        public String Type
        {
            get { return type_; }
            set { type_ = value; }
        }
    }

    public class PersisterInfo
    {
        private String name_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        private ObjectWithArray objectWithArray_;

        public ObjectWithArray ObjectWithArray
        {
            get { return objectWithArray_; }
            set { objectWithArray_ = value; }
        }

        private String connectionName_;

        public String ConnectionName
        {
            get { return connectionName_; }
            set { connectionName_ = value; }
        }

        [XmlElement("CommandInfo")]
        [DictionaryItemAttribute(KeyName = "Name")]
        public Dictionary<String, CommandInfo> Commands
        {
            get 
            {
                if (commands_ == null)
                {
                    commands_ = new Dictionary<String, CommandInfo>();
                }
                return commands_; 
            }
            set { commands_ = value; }
        }

        [DictionaryItemAttribute(KeyName = "Name", KeyValue = "Predefined")]
        [XmlElement("PredefinedCommand")]
        public CommandInfo PredefinedCommand
        {
            get 
            {
                if (!Commands.ContainsKey("Predefined"))
                {
                    CommandInfo cmdInfo = new CommandInfo();
                    Commands["Predefined"] = cmdInfo;
                    return cmdInfo;
                }

                return Commands["Predefined"]; 
            }

            set { Commands["Predefined"] = value; }
        }

        [DictionaryItemAttribute(KeyName = "Name", KeyValue = "Postdefined")]
        [XmlElement("PostdefinedCommand")]
        public CommandInfo PostdefinedCommand
        {
            get
            {
                if (!Commands.ContainsKey("Postdefined"))
                {
                    CommandInfo cmdInfo = new CommandInfo();
                    Commands["Postdefined"] = cmdInfo;
                    return cmdInfo;
                }

                return Commands["Postdefined"];
            }

            set { Commands["Postdefined"] = value; }
        }

        private Dictionary<String, CommandInfo> commands_;

    }

    [XmlRoot("PersisterInfo")]
    public class PersisterInfo2
    {
        private String name_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        private String connectionName_;

        public String ConnectionName
        {
            get { return connectionName_; }
            set { connectionName_ = value; }
        }

        [XmlElement("CommandInfo")]
        [DictionaryItemAttribute(
           KeyName = "Name",
           KeyType = typeof(String),
           ValueType = typeof(CommandInfo)
        )]
        public StringKeyDictionary<CommandInfo> Commands
        {
            get
            {
                if (commands_ == null)
                {
                    commands_ = new StringKeyDictionary<CommandInfo>();
                }
                return commands_;
            }
            set { commands_ = value; }
        }

        [DictionaryItemAttribute(
            KeyName = "Name",
            KeyValue = "Predefined"
        )]
        public CommandInfo PredefinedCommand
        {
            get
            {
                if (!Commands.ContainsKey("Predefined"))
                {
                    CommandInfo cmdInfo = new CommandInfo();
                    Commands["Predefined"] = cmdInfo;
                    return cmdInfo;
                }

                return Commands["Predefined"];
            }

            set { Commands["Predefined"] = value; }
        }

        [DictionaryItemAttribute(
            KeyName = "Name",
            KeyValue = "Postdefined"
        )]
        public CommandInfo PostdefinedCommand
        {
            get
            {
                if (!Commands.ContainsKey("Postdefined"))
                {
                    CommandInfo cmdInfo = new CommandInfo();
                    Commands["Postdefined"] = cmdInfo;
                    return cmdInfo;
                }

                return Commands["Postdefined"];
            }

            set { Commands["Postdefined"] = value; }
        }

        private StringKeyDictionary<CommandInfo> commands_;
    }

    public class ObjectWithArray
    {
        private SampleObject[] sampleObjects_;

        [XmlElementAttribute("SampleObject")]
        public SampleObject[] SampleObjects
        {
            get { return sampleObjects_; }
            set { sampleObjects_ = value; }
        }
    }

    public class ObjectWithIgnoredXmlAttributes
    {
        private String name_;

        [XmlIgnore()]
        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }
    }

    public class ObjectWithEnumerationProperty
    {
        public enum WeekDays
        {
            Saturday, 
            Sunday, 
            Monday, 
            Tuesday, 
            Wednesday, 
            Thursday, 
            Friday
        }

        private WeekDays weekDay_;

        public WeekDays WeekDay
        {
            get { return weekDay_; }
            set { weekDay_ = value; }
        }
    }

}

